Find sequences of one upper case letter¶
pattern = ‘^[a-z]+_[a-z]+$’
Find sequences of one upper case letter followed by lower case letters.
import re
def text_match(S):
pattern = '^[a-z]+_[a-z]+$'
if re.search(pattern, S):
return 'Found a match!'
else:
return('Not matched!')
# test
print(text_match("aab_cbbbc")) # Found a match!
print(text_match("aab_Abbbc")) # Not matched!
print(text_match("Aaab_abbbc")) # Not matched!